<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
	function checkSession() {
		// If the session info hasn't been set...
		if (!$this->Session->check('User')) {
			// Force the user to login
			$this->redirect('/users/login');
			exit ();
		}
	}
	public function beforeFilter() {
		Configure :: write('Config.language', $this->Session->read('Config.language'));
		Configure :: write('Config.language','eng');
		$locale = Configure :: read('Config.language');
		$this->Session->write('Config.language',$locale);
		echo $locale;
		/**
		 * load the ctp files according to the language configuration.
		 */
		if ($locale && file_exists(VIEWS . $locale . DS . $this->viewPath)) {
			// e.g. use /app/View/fre/Pages/tos.ctp instead of /app/View/Pages/tos.ctp
			$this->viewPath = $locale . DS . $this->viewPath;
		}
	}
}
?>
